package com.HW;

/**
 * @ClassName : TstrCutWeight
 * @Author : kele
 * @Date: 2023/10/24 22:01
 * @Description :字符串划分
 */
public class TstrCutWeight {

    public static void main(String[] args) {

        handle("acdbbbca");


    }

    public static void handle(String str) {

        char[] chars = str.toCharArray();

        for (int i = 1; i < chars.length - 3; i++) {

            for (int j = i + 2; j < chars.length - 1; j++) {

                String s1 = str.substring(0, i);
                String s2 = str.substring(i + 1, j);
                String s3 = str.substring(j + 1, chars.length);
                if (Weight(s1) == Weight(s2) && Weight(s2) == Weight(s3)) {
                    System.out.println(i + "," + (j));
                    return;

                }
            }

        }
        System.out.println("0,0");


    }

    public static int Weight(String str) {

        int sum = 0;
        for (char c : str.toCharArray()) {
            sum += (int) c;
        }
        return sum;

    }
}
